<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/struct_info.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/inc/js/infopad.js?2.2"></script>

<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script>
var contextPath='${contextPath}';

$(function(){
	$("#center_id").val("<#if zhichu??>${zhichu.center_id}</#if>");
	
	$('#center_id').change(function(){
		var center_id = $("#center_id").val();
		if(center_id=="" || center_id==undefined){
			$("#methodMsg").html("");
			return;
		}
		$.post("${contextPath}/index/get_method.json", {
			"center_id" : center_id
		}, function(ms) {
			var list = ms.list;
			if(list!=null && list.length>0){
				var objHtml = "";
				for(var i=0;i<list.length;i++){
					objHtml += '<option value="'+list[i].id+'">'+list[i].name+'</option>';
				}
				$("#methodMsg").html('<select id="method_id">'+objHtml+'</select>');
			}else{
				$("#methodMsg").html("");
			}
		});
	});
	
	var center_id = "<#if zhichu??>${zhichu.center_id}</#if>";
	if(center_id!=null){
		$.post("${contextPath}/index/get_method.json", {
			"center_id" : center_id
		}, function(ms) {
			var list = ms.list;
			if(list!=null && list.length>0){
				var objHtml = "";
				for(var i=0;i<list.length;i++){
					objHtml += '<option value="'+list[i].id+'">'+list[i].name+'</option>';
				}
				$("#methodMsg").html('<select id="method_id">'+objHtml+'</select>');
			}else{
				$("#methodMsg").html("");
			}
			$("#method_id").val("<#if zhichu??>${zhichu.method_id}</#if>");
			
		});
	}
	
});

var addZhichu = function(){
	var id = $("#id").val();
	var moneyDate = $("#moneyDate").val();
	var zhaiyao = $("#zhaiyao").val();
	var center_id = $("#center_id").val();
	var method_id = $("#method_id").val();
	var moneys = $("#moneys").val();
	var beizhu = $("#beizhu").val();
	
	if(moneyDate==""){
		infopad.err("请选择缴费日期!");
		return;
	}
	if(center_id==""){
		infopad.err("请选择中心!");
		return;
	}
	if(method_id==""){
		infopad.err("请选择支付方式!");
		return;
	}
	if(moneys==""){
		infopad.err("请填写金额!");
		return;
	}
	
	$.post("${contextPath}/index/add_zhichu_moneys_go.json", {
			"id":id,
			"moneyDate":moneyDate,
			"zhaiyao":zhaiyao,
			"center_id":center_id,
			"method_id":method_id,
			"moneys":moneys,
			"beizhu":beizhu
		}, function(ms) {
		    var msg = ms.msg;
		    if(msg!=null && msg=="1"){
				infopad.msg("操作成功！");
		    }else{
		    	infopad.err("操作失败，请联系管理员！");
		    }
			
	});
};

</script>
</head>
<input type="hidden" id="id" value="<#if zhichu??>${zhichu.id}</#if>">
<body>
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>组织架构</li>
			<li>&gt;</li>
			<li class="current">title</li>
		</ul>
	</div>

	<div id="container">
		<div id="title">添加中心支出</div>
		<table id="infotable">
			<tr>
				<th>缴费日期:</th>
				<td style="height:20px;">
					<input type="text" id="moneyDate" value="<#if zhichu??>${zhichu.moneyDate}</#if>" rel="DATE::Y-m-d" value="" size="15" maxlength="15" readonly="readonly" class="DatePicker_Icon">
				</td>
			</tr>
			<tr>
				<th>摘要:</th>
				<td><input id="zhaiyao" type="text" value="<#if zhichu??>${zhichu.zhaiyao}</#if>" size="50" maxlength="30" /></td>
			</tr>
			<tr>
				<th>办公地址:</th>
				<td>
				<select id="center_id">
					<option value="">请选择中心</option>
					<#if offList??>
						<#list offList as list>
							<option value="${list.id}">${list.name}</option>
						</#list>
					</#if>
				</select>
				</td>
			</tr>
			<tr>
				<th>支付方式</th>
				<td style="height:20px;" id="methodMsg"></td>
			</tr>
			<tr>
				<th>支付金额</th>
				<td><input id="moneys" value="<#if zhichu??>${zhichu.moneys}</#if>" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9.]/g,'')" type="text" size="20" maxlength="10" />元</td>
			</tr>
			<tr>
				<th>备注</th>
				<td><textArea id="beizhu" type="text" style="width:366px;height:111px;" /><#if zhichu??>${zhichu.beizhu}</#if></textArea>
			</tr>
		</table>
		<div id="controlbar">
			<input type="button" class="submit" onclick="addZhichu()" value="  保  存  " />
		</div>
	</div>
	
</body>
</html>